package com.lyhengtongwl.zqsnews.adapter;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lyhengtongwl.zqsnews.App;
import com.lyhengtongwl.zqsnews.R;
import com.lyhengtongwl.zqsnews.entity.NewsEntity;
import com.lyhengtongwl.zqsnews.utils.FTYUtils;
import com.makeramen.roundedimageview.RoundedImageView;
import com.squareup.picasso.Picasso;

import java.util.List;

public class NewsPublicAdataper extends BaseQuickAdapter<NewsEntity, BaseViewHolder> {
    private Activity activity;
    private String newsType;
    private ImageView imageView;
    private String type;

    public NewsPublicAdataper(Activity activity, List<NewsEntity> newsList,String type) {
        super(R.layout.item_news, newsList);
        this.activity = activity;
        this.newsType = newsType;
        this.type=type;
    }


    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(BaseViewHolder helper, NewsEntity item) {
        String title = item.getTitle();
        String linkUrl = item.getUrl();
        String money = item.getMoney();
        TextView tt=((TextView) helper.getView(R.id.tv_title));
        TextView tm=((TextView) helper.getView(R.id.tv_money));
        TextView tf=((TextView) helper.getView(R.id.tv_forward));
        TextView tl=((TextView) helper.getView(R.id.tv_gg));
            tf.setVisibility(View.VISIBLE);
            tt.setText(title);
            if ("1".equals(type)){
//                tm.setText("￥" + FTYUtils.fenToYuan(money).split("\\.")[0]);
                tl.setText(item.getCreateTime().substring(0,10));
            }else {
                tm.setText("￥" + FTYUtils.fenToYuan(money).split("\\.")[0]);
                tl.setText("累计收益");
            }
            tf.setText("转发赚钱");
//            (helper.getView(R.id.tv_forward)).setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View view) {
//                    activity.startActivity(new Intent(activity, NewsWebDetailActivity.class).putExtra("url", item.getContentUrl()));
//                }
//            });
            Picasso.with(App.getContext()).load(linkUrl).placeholder(R.mipmap.error).error(R.mipmap.error).into((RoundedImageView) helper.getView(R.id.iv_preview));

    }


}
